package changestu

import (
	"fmt"
)

//可变参数
func ChangeStu() {

	mm := cp("hello", "word", "hello", "lilei")
	fmt.Println(mm)

	//把切片传入可变参数的方法
	ar := []string{"a", "b", "c", "d", "c"}
	fmt.Println(cp2(len(ar), ar...))

}

//可变参数只能放在最后
func cp2(length int, word ...string) map[string]int {
	mp := make(map[string]int, length)
	for _, v := range word {
		mp[v]++
	}
	return mp
}

//单词计数
func cp(word ...string) map[string]int {
	mp := make(map[string]int, 6)
	for _, v := range word {
		mp[v]++
	}
	return mp
}
